package com.example.myactspringboot.server;

import com.example.myactspringboot.bean.SysRole;
import com.example.myactspringboot.dao.SysRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Create 2023-09-24 14:36
 * @Description
 */
@Service
public class RoleService {
    @Autowired
    private SysRoleMapper mapper;

    public List<SysRole> getAllRole(){
        List<SysRole> allRole = mapper.getAllRole();
        return allRole;
    }

    @Transactional
    public int delRelevanceRole(String roleId){
        int i = mapper.delRoleById(roleId);
        mapper.delRoleMenuByRoleId(roleId);
        int i1 = mapper.delRoleUserByRoleId(roleId);
        return i;
    }

    public SysRole getById(String roleId){
        SysRole roleById = mapper.getRoleById(roleId);
        return roleById;
    }

}
